import { GaRegExp, ruleInject, ruleInjectable } from "../InjectionRule";
import { blankRemove } from "../methods/blank-remove";
import { MakeListRule } from "../methods/make-list";

@ruleInjectable()
export default class importRule extends GaRegExp {

	@ruleInject() private variableNameRule!: GaRegExp;

	@ruleInject() private stringRule!: GaRegExp;

	public RuleInit() {
		this.ParseRule([
			"import", "\\s",
			this.Supply("IMPORT"),
			blankRemove,
			"(&",
			"(-",
			"(", "(", this.variableNameRule, ")", blankRemove, "(&", "as", blankRemove, this.variableNameRule, ")?", ")", "()", blankRemove,
			"|", "()", "\\{", ...MakeListRule(["(", this.variableNameRule, ")", blankRemove, "(&", "as", blankRemove, this.variableNameRule, ")?"]), "\\}",
			"|", "(", "(", this.variableNameRule, ")", blankRemove, "(&", "as", blankRemove, this.variableNameRule, ")?", ")", blankRemove,
			"(&", ",", blankRemove, "\\{", ...MakeListRule(["(", this.variableNameRule, ")", blankRemove, "(&", "as", blankRemove, this.variableNameRule, ")?"]), "\\}", ")",
			")",
			blankRemove, "from", blankRemove,
			")?",
			"(", this.stringRule, ")",
			blankRemove,
			";",
		]);
	}

}
